<template>
	<view class="content">
		<template v-if="list.length>0">
			<view class="info-block" v-for="(item,index) in list" :key="item.id"
				@click="navigate('/page_other/look/detail?id='+item.id)">
				<view style="display: flex; flex-direction: row;padding: 30rpx;">
					<image :src="item.faceUrl"
						style="width: 80rpx;height: 80rpx; border-radius: 50%; background-color: #f5f5f5;margin-right: 30rpx;">
					</image>
					<view class="info-list">
						<view class="name">{{item.userName}}</view>
						<view class="text">{{item.content}}</view>
						<view class="img-list">
							<image :src="item1" class="img-item" mode="aspectFill"
								v-for="(item1,index1) in item.picList" :key="index1">
							</image>
						</view>
						<view class="address-item">
							<image src="../../static/look/position.png" class="iconfont"></image>
							<view class="address">{{item.address}}</view>
						</view>
						<view class="info-item">
							<view class="time-item">
								<image src="../../static/look/time.png" class="iconfont"></image>
								<view class="time">{{item.crtTimeText}}</view>
							</view>
							<view class="state" v-if="item.status==0">待处理</view>
							<view class="state1" v-else-if="item.status==3">结案</view>
							<view class="state3" v-else>已受理</view>
						</view>
					</view>
				</view>
			</view>
		</template>
		<view v-else-if="list.length==0&&!listConf.more" style="text-align: center;">暂无数据</view>
		<view v-if="list.length>0&&!listConf.more" style="text-align: center;">没有更多了</view>
	</view>
</template>

<script>
	import {
		getPageFormList
	} from '@/api/look.js'
	import {
		isMore
	} from '@/util/util.js'
	import {
		getStorage
	} from '@/util/auth.js'
	export default {
		data() {
			return {
				list: [],
				listConf: {
					page: 1,
					limit: 10,
					more: true,
				}
			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getPageFormList({
					page: this.listConf.page,
					limit: this.listConf.limit
				}).then(data => {
					uni.hideLoading()
					let list = data.list || [];
					list.forEach((item, index) => {
						if (list[index].picList && list[index].picList.length > 0) {
							list[index].picList = list[index].picList[0].url.split(',');
							list[index].picList = list[index].picList.splice(0, 2)
						}
					})
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.listConf.more = isMore(this.listConf.page, this.listConf.limit, data.count);
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		// mounted() {
		// 	this.getList(true)
		// },
		onReachBottom() {
			if (this.listConf.more) {
				this.listConf.page++;
				this.getList()
			}
		},
		onLoad() {
			this.getList(true)
		}
	}
</script>

<style lang="scss">
	page {
		background: #FAFAFA;
	}

	.content {
		padding: 30rpx;

		.info-block {
			width: 100%;
			height: auto;
			background: #fff;
			box-shadow: 0 0 10px 0 #dedede;
			border-radius: 20rpx;
			margin-bottom: 30rpx;

			.info-list {
				width: calc(100% - 120rpx);
				display: flex;
				flex-direction: column;
				font-size: 34rpx;

				.name {
					color: #027BFD;
					margin-bottom: 10rpx;
					font-weight: 600;
				}

				.text {
					font-size: 28rpx;
					font-weight: 500;
					word-break: keep-all;
					word-wrap: break-word;
					white-space: pre-line;
				}

				.img-list {
					display: flex;
					flex-direction: row;
					flex-wrap: wrap;
					margin-top: 30rpx;

					.img-item {
						width: calc((100% - 20rpx)/2);
						height: 200rpx;
						margin-right: 20rpx;
						margin-bottom: 20rpx;
						border-radius: 20rpx;
					}

					.img-item:last-child {
						margin-right: 0;
					}
				}

				.address-item {
					width: 100%;
					margin-top: 30rpx;
					display: flex;
					flex-direction: row;
					align-items: center;

					.iconfont {
						width: 28rpx;
						height: 35rpx;
						margin-right: 20rpx;
					}

					.address {
						width: calc(100% - 60rpx);
						color: #027BFD;
						font-size: 28rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
				}

				.info-item {
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					margin-top: 30rpx;

					.time-item {
						color: #999;
						display: flex;
						flex-direction: row;
						align-items: center;

						.iconfont {
							width: 30rpx;
							height: 30rpx;
							margin-right: 20rpx;
						}

						.time {
							font-size: 28rpx;
						}
					}

					.state {
						color: #027BFD;
						font-size: 28rpx;
					}

					.state1 {
						color: #47A244;
						font-size: 28rpx;
					}

					.state2 {
						color: #D7080A;
						font-size: 28rpx;
					}

					.state3 {
						color: #FE7526;
						font-size: 28rpx;
					}
				}
			}
		}
	}
</style>